<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>领域驱动开发平台控制台v1.0</title>
	<link id="easyuiTheme" href="../static/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<script src="../static/easyui/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/easyui/jquery.easyui.ext.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/easyui/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/easyui/ui-theme.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/plugin/assets/jslib.util.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/plugin/assets/jslib.menu.js" type="text/javascript" charset="utf-8"></script>
	<link href="../static/css/normalize.css?twitterbutton" rel="stylesheet" type="text/css"/>
	<link href="../static/css/tricks.css?twitterbutton" rel="stylesheet" type="text/css"/>
	<link href="../static/css/elusive-webfont.css?twitterbutton" rel="stylesheet" type="text/css"/>
	<link href="../static/css/codemirror.css?twitterbutton" rel="stylesheet" type="text/css"/>
	<link href="../static/css/screen.css?twitterbutton" rel="stylesheet" type="text/css"/>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
	<style type="text/css">
		.easytop{height: 44px;width:100%;background-color: #224a7d;overflow: hidden}
		.drownhead{float:left;margin-top:12px;margin-right:20px;}
		.drownmenu{display: none;min-width:120px;position:absolute;z-index:5;box-shadow: #c0c0c0 2px 2px 2px;background-color:#F9F9F9;border: 1px solid #9e9c9c;border-radius:5px;}
		.drowntitle{color:white;font-size:16px; font-weight:600;}

		.drowntitle:after {
			content: '';
			margin-top:8px;
			margin-left:3px;
			position:absolute;
			height: 6px;
			width: 6px;
			background: linear-gradient(135deg,white 0%,white 50%,transparent 50%,transparent 100%);
			transform: rotate(225deg);}
		.drowntitle.hidden:after {display: none;}
		.drownmenu.show{display:block;}

		.drownhead a{text-decoration:none;}
		.drownmenu div{display:inline-block;vertical-align: top;}
		.drownmenu a{text-decoration:none;border: 1px solid #F9F9F9;font-size: 15px;margin:5px;display:block;}
		.drownmenu span{color:#c0c0c0;font-size: 15px;display:block;margin:5px;}

		.drowntitle:hover{color: #adb5ff;}
		.drowntitle:hover::after{background:linear-gradient(135deg, #adb5ff 0%, #adb5ff 50%,transparent 50%,transparent 100%);}
		.drownmenu a:hover{background-color: #e9f4ff;border: 1px solid #a1a9ec;border-radius:5px;border-radius:3px;color:#17173C;}
	</style>
</head>
<script languange="javascript" defer>

	var funcOps;
	var loginUserId;
	var subsCode;
	var themes = [
		{value:'default',text:'Default',group:'Base'},
		{value:'gray',text:'Gray',group:'Base'},
		{value:'metro',text:'Metro',group:'Base'},
		{value:'material',text:'Material',group:'Base'},
		{value:'material-teal',text:'Material Teal',group:'Base'},
		{value:'material-blue',text:'Material Blue',group:'Base'},
		{value:'bootstrap',text:'Bootstrap',group:'Base'},
		{value:'black',text:'Black',group:'Base'},
		{value:'metro-blue',text:'Metro Blue',group:'Metro'},
		{value:'metro-gray',text:'Metro Gray',group:'Metro'},
		{value:'metro-green',text:'Metro Green',group:'Metro'},
		{value:'metro-orange',text:'Metro Orange',group:'Metro'},
		{value:'metro-red',text:'Metro Red',group:'Metro'},
		{value:'ui-cupertino',text:'Cupertino',group:'UI'},
		{value:'ui-dark-hive',text:'Dark Hive',group:'UI'},
		{value:'ui-pepper-grinder',text:'Pepper Grinder',group:'UI'},
		{value:'ui-sunny',text:'Sunny',group:'UI'}
	];

	window.onload=function(){
		getUserInfo();
		themeInite();
	};

	//获取用户信息
	function getUserInfo() {
		if ($('#tt').tabs('exists', "首页")){
			$('#tt').tabs('select', "首页");
		} else {
			var content = '<iframe scrolling="auto" frameborder="0" src="' + "admin/HomePage.html" + '" style="width:100%;height:100%;"></iframe>';
			$('#tt').tabs('add', {
				title: "首页",
				content: content
			});
		}
		$.ajax({
			type: "post",
			url: '../api/admin/menus',
			data: {
			},
			success: function(data) {
				createPersonHtml(data.rows.actorName);
				loginUserId = data.rows.actorNo;
				getSSubsInfo(loginUserId);
			}
		});
	}

	//获取子系统列表
	function getSSubsInfo(actorNo) {
		$.ajax({
			type: "post",
			url: '../api/s/user/subs/info/'+actorNo,
			data: {
			},
			success: function(data) {
				if(data.rows.length>0)
					createSubsHtml(data.rows);
				else
					$.messager.alert('提示','当前用户子系统菜单为空！','info');
			}
		});
	}

	function createSubsHtml(menus){
		var subsHtml="";
		for(var i=0;i<menus.length;i++){
			subsHtml += "<ul><a  href='#' id='" + menus[i].subsCode + "' onclick='getTreeBySystempk(this.id);window.event.returnValue=false'>";
			subsHtml += menus[i].subsName+"</a></ul>";
		}
		document.getElementById("subsMenu").innerHTML = subsHtml.toString();
		if(menus.length=1){
			$("#title .drownhead").addClass("focus").css("pointer-events","none");
			$("#title .drowntitle").addClass('hidden');
		}else{
			losed("subs");
		}
		// getTreeBySystempk(menus[0].subsCode);
		getTreeBySystempk('console');
	}


	//根据subs_code获得资源
	function getTreeBySystempk(systempk) {
		subsCode=systempk;
		$("#subs").text($("#"+systempk).text());
		document.title=$("#"+systempk).text();
		$.ajax({
			type: "POST",
			url: "../api/s/resource/all/" +systempk ,
			data: {
			},
			success: function(data) {
				createRootMenusHtml(data,systempk);
			}
		});
	}

	//创建导航栏菜单
	function createRootMenusHtml(menus,systempk) {
		var menuTopHtml = "";
		var menusHtml="";
		if (menus != null && menus.length > 0) {
			for (var i = 0; i < menus.length; i++) {
				if(menus[i].parentId==systempk){
					if(menus[i].children.length>0){
						menuTopHtml += "<li class='drownhead'>";
						menuTopHtml += ("<a class='drowntitle' id='"+menus[i].id+"' href='#'onclick='menuController(this.id);window.event.returnValue=false'>");
						menuTopHtml += menus[i].text+"</a><ul class='drownmenu' id='"+menus[i].id+"Menu'><ul style='margin:5px'>"+createChildrenHtml(menus[i])+"</ul></ul></li>";
					}else{
						menuTopHtml += "<li class='drownhead'>";
						menuTopHtml += ("<a class='drowntitle hidden' href='#'>");
						menuTopHtml += menus[i].text+"</a></li>";
					}
				}
			}
		}else{
			$.messager.alert('提示','菜单为空！','info');
		}
		document.getElementById("menusTop").innerHTML = menuTopHtml.toString();
		for (var i = 0; i < menus.length; i++)
			if(menus[i].children.length>0)
				losed(menus[i].id);
	}
	//创建子菜单html语句
	function createChildrenHtml(node){
		var childrenHtml="";
		for(var i=0;i<node.children.length;i++){
			var currentNode=node.children[i];
			if(currentNode.children.length != 0){
				childrenHtml+="<div><ul><span>"+ currentNode.text +"</span>"+ createChildrenHtml(currentNode)+"</ul></div>";
			}else{
				childrenHtml+="<ul><a href=\"javascript:addTab('"+currentNode.text+"','"+currentNode.url+"');\" id='"+ currentNode.id +"'>"+ currentNode.text +"</a></ul>";
			}
		}
		return childrenHtml;
	}

	function losed(node){
		$('#'+node).hover(function(){
			$('#'+node+'Menu').addClass('show');
		},function(){
			$('.drownmenu') .removeClass('show');
		})
		$('#'+node+'Menu').hover(function(){
			$('#'+node+'Menu').addClass('show');
		},function(){
			$('.drownmenu') .removeClass('show');
		})
	}

	$(document).click(function (event){
		if ($("#"+event.target.id).attr("class") != "drowntitle")
			$('.drownmenu') .removeClass('show');
	});

	//创建用户HTML
	function createPersonHtml(userName) {
		$('#userName').text(userName);
	}

	function addTab(title, url){
		if ($('#tt').tabs('exists', title)){
			$('#tt').tabs('select', title);
		} else {
			var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
			$('#tt').tabs('add',{
				title:title,
				content:content,
				closable:true
			});
		}
	}

	//根据菜单ID获取资源操作码值字符串
	function getFuncOpStr(resourceId) {
		var result = "";
		if(null != funcOps && funcOps.length > 0){
			for(var i = 0; i < funcOps.length; i++){
				if(resourceId == funcOps[i].resourceid){
					result = result + funcOps[i].actid + ",";
				}
			}
		}
		return result;
	}

	//退出系统
	function loginOut() {
		$.restfulPostJson('../api/logout', null, function(data) {
			if(data.code == '0' && data.rows == true) {
				$(window.location).attr("href", "../login.html");
			} else {
				if(data.message) {
					alert(data.message);
				} else {
					alert("登出失败！");
				}
			}
		})
	}

	//更换风格
	function changeThemeStyle() {
		JLEUtil.createModalWin('更换风格', '../uistyle.html', 0.5);
	}

	//修改密码
	function modifyPassword() {
		addTab("修改密码", "admin/ModifyPassword.html");
	}

	/**
	 * 更换主题
	 */
	changeTheme = function(type){
		var easyuiTheme = $('#easyuiTheme');
		var url = easyuiTheme.attr('href');
		var href ="../static/easyui/themes/"+type+"/easyui.css";
		var href2 = "../../static/easyui/themes/"+type+"/easyui.css";
		easyuiTheme.attr('href',href);
		// 如果使用了iframe  则要添加下面这段代码、否则的话iframe中的内容不会出现样式的改变
		var $iframe = $('iframe');
		if($iframe.length > 0){
			for ( var i = 0; i < $iframe.length; i++) {
				var ifr = $iframe[i];
				$(ifr).contents().find('#easyuiTheme').attr('href', href2);
			}
		}
		$.cookie('easyuiThemeName', type, {
			expires : 7
		});
	};
	//选择主题方案
	function  themeInite(){
		var easyuiTheme = $.cookie('easyuiThemeName');
		if (easyuiTheme==null){
			easyuiTheme = "bootstrap"
		}
		changeTheme(easyuiTheme);
	};

	function changeThemeStyle(theme) {
		$.cookie('theme', theme);
		// 切换风格
		var themepath = 'page';
		if (theme == 'bootstrap') {
			themepath = 'vue';
		} else if (theme == 'react') {
			themepath = 'react'
		} else {
			// 默认是easyui
			themepath = 'page';
		}
		window.parent.location.href = '../'+themepath+'/index.html';
	};

</script>
<body class="easyui-layout"style="width:100%;height:100%">
<div id="cc" data-options="region:'center',title:''" style="position:relative;z-index:4;overflow: hidden;">
	<div class="easytop">
		<div id="branding" >
			<ul class="actionCont left" id="title">
				<li class="drownhead"style="margin-left: 12px;white-space:nowrap;">
					<a class="drowntitle" href="#" id="subs">领域驱动开发平台v1.0</a>
					<ul id="subsMenu" class="drownmenu">

					</ul>
				</li>
			</ul>
		</div>
		<div id="actions">
			<ul class="actionCont collapsed">
				<li class="drownhead" style="margin-right: 12px;"><a class="drowntitle hidden" href="javascript:addTab('首页','admin/HomePage.html')"><span>首页</span></a></li>
			</ul>
			<ul class="actionCont collapsed" id="menusTop">

			</ul>
			<ul class="actionCont right">
				<li class="actionItem jobboard" >
					<a href="#" class="easyui-menubutton"
					   style="margin-top: 10px; "
					   data-options="menu:'#userMenu',iconCls:'icon-man'" plain="true"><span id="userName" style=" color: white;font-weight: 800;font-size: 15px">&nbsp;&nbsp;</span></a>
				</li>
			</ul>
		</div>
	</div>

	<div id="tt" class="easyui-tabs" fit="true" border="false" >
		<!-- <div title="运行流程监控" style="padding:0px" border="false" fit="true">
            <iframe id="infoFrame" name="centerFrame" src="bpm-console/BpaInstInfoList.html" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>
        </div> -->
	</div>
</div>


<div id="userMenu" style="width: 180px;border-radius:5px;">
	<div onclick="modifyPassword()">修改密码</div>

	<div >
		<span class="layout-panel-east">更换风格</span>
		<div>
			<div onclick="javascript:changeThemeStyle('easyui')">easyui</div>
			<div onclick="javascript:changeThemeStyle('bootstrap')">bootstrap</div>
			<div onclick="javascript:changeThemeStyle('react')">react</div>
		</div>

	</div>
	<div>
		<span class="layout-panel-east">主题更改</span>
		<div style="width:100px;">
			<div onclick="javascript:changeTheme('default')">Default</div>
			<div onclick="javascript:changeTheme('gray')">Gray</div>
			<div onclick="javascript:changeTheme('metro')">Metro</div>
			<div onclick="javascript:changeTheme('material')">Material</div>
			<div onclick="javascript:changeTheme('material-teal')">Material Teal</div>
			<div onclick="javascript:changeTheme('material-blue')">Material Blue</div>
			<div onclick="javascript:changeTheme('bootstrap')">Bootstrap</div>
			<div onclick="javascript:changeTheme('black')">Black</div>
			<div onclick="javascript:changeTheme('metro-blue')">Black</div>
			<div onclick="javascript:changeTheme('metro-gray')">Metro Gray</div>
			<div onclick="javascript:changeTheme('metro-green')">Metro Green</div>
			<div onclick="javascript:changeTheme('metro-orange')">Metro Orange</div>
			<div onclick="javascript:changeTheme('metro-red')">Metro Red</div>
			<div onclick="javascript:changeTheme('ui-cupertino')">Cupertino</div>
			<div onclick="javascript:changeTheme('ui-dark-hive')">ark Hive</div>
			<div onclick="javascript:changeTheme('ui-pepper-grinder')">Cupertino</div>
			<div onclick="javascript:changeTheme('ui-pepper-grinder')">Pepper Grinder</div>
			<div onclick="javascript:changeTheme('ui-sunny')">Sunny</div>
		</div>
	</div>
	<div onclick="loginOut()">注销退出</div>
</div>

</body>
</html>